// preset before starting RTC
class Presetting {
  init() {
    // populate userId/roomId
    // $('#userId').val('user_' + parseInt(Math.random() * 100000000));
    // $('#roomId').val(parseInt(Math.random() * 100000));
    this.roomId = this.query('roomId');
    this.userId = this.query('userId');
    this.userSig = this.query('userSig');
    // if (roomId) {
    //   $('#roomId').val(roomId);
    // }
    // if (userId) {
    //   $('#userId').val(userId);
    // }

    $('#main-video-btns').hide();
    $('.mask').hide();
    setBtnClickFuc();
    login();

  }

  query(name) {
    const match = window.location.search.match(new RegExp('(\\?|&)' + name + '=([^&]*)(&|$)'));
    return !match ? '' : decodeURIComponent(match[2]);
  }

  login(share, callback) {
    // let userId = $('#userId').val();
    let userId = this.userId;
    if (share) {
      userId = 'share_' + userId;
    }
    // const config = genTestUserSig(userId);
    // const sdkAppId = config.sdkAppId;
    // const userSig = config.userSig;
    // const roomId = $('#roomId').val();
    const sdkAppId = 1400369812;
    const userSig = this.userSig;
    const roomId = this.roomId;

    callback({
      sdkAppId,
      userId,
      userSig,
      roomId
    });
  }
}
